package ConstDef;

require Exporter;
@ISA    = qw(Exporter);
@EXPORT = qw(MaxNameLength
  MaxCodeLength);

#For constant value, we can use "use constant" statement and export such symbols
#to package space.
use constant MaxNameLength => 1000;
use constant MaxCodeLength => 2000;


#use constant in hash tables as the key.
use constant NodeType => "MSC";
my %hash = ( 
NodeType  => 1, #These two methods are different.
NodeType() => 1
);
#> How can I use a "constant" as a hash key?
#> 
#> $ perl -e 'use constant CAT=>A;
#>> $hash{CAT} = q{Bobby};
#>> $hash{"CAT"} = q{Muffy};
#>> $hash{'CAT'} = q{Fluffy};
#>> $hash{qq{CAT}} = q{Tuffy};
#>> print "$_ = $hash{$_}\n" foreach (keys %hash);'
#> CAT = Tuffy
#> $
#> 
#> Want...
#> 
#> A=Bobby
#
#If you remember that constants are implemented as subroutines then all you have
#to do is write the hash key as an expression that forces the subroutine to be
#called. So
#
#  use constant CAT => 'A';
#
#is equivalent to
#
#  sub CAT { 'A' }
#
#and you can access the hash element with an expression like
#
#  $hash{CAT()} = 'Daffy';
#  $hash{CAT} = 'Duffy';
#  $hash{CAT.''} = 'Dippy';
#  $hash{0 || CAT} = 'Depot';
#
#HTH,
#
#Rob
